package com.example.tp_1;

import java.util.ArrayList;
import java.util.HashMap;

import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.SimpleAdapter;
import android.widget.Toast;

import com.example.sqlite.DM_Society_Boutique;



public class Recherche_par_marque extends Activity implements android.view.View.OnClickListener
{
	private ArrayList<HashMap<String, String>> lArrayList;
	
	private DM_Society_Boutique _myDMSociety_Article;
	private Button _valider;
	private Button _annuler;
	private EditText _marque;
	
   public void onCreate(Bundle savedInstanceState)
   {
	   super.onCreate(savedInstanceState);
	   setContentView(R.layout.recherche_par_marque);
	   
	   _myDMSociety_Article=new DM_Society_Boutique(this);
	   
	   _valider=(Button) findViewById(R.id.Tp1_consulter_articles_recherche_marque_button_valider);
	   _annuler=(Button) findViewById(R.id.Tp1_consulter_articles_recherche_marque_button_annuler);
	   _marque=(EditText) findViewById(R.id.Tp1_consulter_articles_recherche_marque_editText_nom_marque);
	    
	   _valider.setOnClickListener(this);
	   _annuler.setOnClickListener(this);
   }
   public void onClick(View v)
   {
	   switch (v.getId())
	   {
	case R.id.Tp1_consulter_articles_recherche_marque_button_valider:
		
		Recherche();
		
		break;
    case R.id.Tp1_consulter_articles_recherche_marque_button_annuler:
		
		break;
   
	default:
		break;
	}
   }
   
   public void Recherche()
   {
	   
	   
	   lArrayList=_myDMSociety_Article.rechercheArticle(_marque.getText().toString());
	
	   SimpleAdapter lAdapter = new SimpleAdapter(Recherche_par_marque.this, lArrayList, R.layout.strocture_alertdialog_recherche_article, new String[] {"KEY_REF","KEY_CONST","KEY_PIX","KEY_CARACT"}, new int[] {R.id.Tp1_consulter_articles_recherche_marque_textView_Ref,R.id.Tp1_consulter_articles_recherche_marque_textView_Constructeur,R.id.Tp1_consulter_articles_recherche_marque_textView_Prix,R.id.Tp1_consulter_articles_recherche_marque_textView_Caracteristique});

	   AlertDialog.Builder builder = new AlertDialog.Builder(this);
	   builder.setSingleChoiceItems(lAdapter, -1, null);
	   
	   builder.show();
       
   }
}
